<template>
  <el-dialog
    :title="$language.local(title)"
    :visible.sync="dialogVisible"
    width="40%"
  >
    <el-form
      ref="formRef"
      :model="formData"
      :rules="$rules"
      label-width="100px"
      status-icon
    >
      <el-form-item>
        <upload-file v-model="formData.ExcelUrl" :drag="true">
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击选择</em></div>
          <div class="el-upload__tip" slot="tip">上传文件不超过 5 MB</div>
        </upload-file>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">{{
        $language.local("取消")
      }}</el-button>
      <el-button type="primary" @click="onSubmit('formRef')">{{
        $language.local("确定")
      }}</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  props: {
    value: String,
    dialogVisible: Boolean,
    title: String,
  },
  data() {
    return {
      formData: {
        uploadedUrl: "",
      },
    };
  },
  methods: {
    async onSubmit(formName) {
      let valided = await this.$refs[formName].validate().catch((err) => err);
      if (!valided) {
        return;
      }
      console.log(this.formData);
    },
    onSuccess(e) {
      console.log(e);
    },
  },
};
</script>

<style></style>
